﻿Imports MapWindow.Map
Imports MapWindow.PluginInterfaces
Imports MapWindow.Data
Imports MapWindow.Drawing

Public Class InfoForm

    'The _mapWin object is used for communicating
    'with the main application
    Private _mapWin As IMapPluginArgs

    Public Sub New(ByVal mapWin As IMapPluginArgs)
        InitializeComponent()
        _mapWin = mapWin
    End Sub

    Protected Overrides Sub OnClosing(ByVal e As System.ComponentModel.CancelEventArgs)
        e.Cancel = True
        Me.Hide()
    End Sub

    Public Sub UpdateLayerInfo()
        'loop through all map layers and show information
        Dim numLayers As Integer = _mapWin.Map.Layers.Count

        If numLayers > 0 Then
            lblNumLayers.Text = numLayers.ToString()
        End If

        Me.txtInfo.Clear()

        For Each lay As Layer In _mapWin.Map.Layers
            'get the feature layer
            Dim fl As FeatureLayer = CType(lay, FeatureLayer)
            'get the source feature set
            Dim ds As FeatureSet = CType(lay.DataSet, FeatureSet)
            'display information about the source feature set
            If Not ds Is Nothing Then
                txtInfo.AppendText(vbCrLf & lay.LegendText & " " & _
                                   ds.Features.Count & " shapes")
            End If         
        Next
    End Sub
End Class